﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kaiser.Modules.Core.Aggregates;

namespace Kaiser.Modules.Core.Services
{
    public class FlowBillsService : Kaiser.Services.ServiceBase<FlowBills>
    {
        public delegate void AddFlowBillsDelegate(FlowBills item);
        private event AddFlowBillsDelegate AddFlowBillsEvent;

        protected virtual void OnAddFlowBillsEvent(FlowBills item)
        {
            AddFlowBillsDelegate handler = AddFlowBillsEvent;
            if (handler != null) handler(item);
        }

        public FlowBillsService()
        {
            AddFlowBillsEvent += FlowBillsService_AddFlowBillsEvent;
        }

        void FlowBillsService_AddFlowBillsEvent(FlowBills item)
        {
           
            FlowBills.Add(item);
        }

        public void AddFlowBills(FlowBills item)
        {
            AddFlowBillsEvent(item);
            //跟新结算账户
            item.SettleAcct.UpdateCurAmount(item.SettleAcct.CurAmount+item.InAmount);
        }
    }
}
